#include<bits/stdc++.h>
using namespace std;
const int inf=2147483647;
struct node{
    int d,v,a;
}c[100055];
struct pppp{
    int l,r; 
}q[100055];
int T;
int n,m,L,V,p[100055],ans1,ans2,maxx,tot;
bool cmp(pppp x,pppp y){
    if(x.r!=y.r) return x.r<y.r;
    return x.l<y.l;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T--){
        tot=ans1=ans2=0;
        scanf("%d%d%d%d",&n,&m,&L,&V);
        for(int i=1;i<=n;i++){
            scanf("%d%d%d",&c[i].d,&c[i].v,&c[i].a);
        }
        for(int i=1;i<=m;i++) scanf("%d",&p[i]);
        maxx=p[m];
        p[m+1]=inf;
        for(int i=1;i<=n;i++){
            if(c[i].d>maxx) continue;
            if(c[i].a==0&&c[i].v>V){
                int t=lower_bound(p+1,p+m+1,c[i].d)-p-1;
                ans1++;
                q[++tot].l=t+1;
                q[tot].r=m;
            }
            if(c[i].a>0){
                if(c[i].v>V){
                    int t=lower_bound(p+1,p+m+1,c[i].d)-p-1;
                    ans1++;
                    q[++tot].l=t+1;
                    q[tot].r=m;
                }
                else{
                    int td=(V*V-c[i].v*c[i].v)/(2*c[i].a)+c[i].d+1;
                    if(td>maxx) continue;
                    int t=lower_bound(p+1,p+m+1,td)-p-1;
                    ans1++;
                    q[++tot].l=t+1;
                    q[tot].r=m;
                }
            }
            if(c[i].a<0&&c[i].v>V){
                int td=(c[i].v*c[i].v-V*V)/(-2*c[i].a)+c[i].d;
                if((c[i].v*c[i].v-V*V)%(-2*c[i].a)==0) td--;
                int t1=lower_bound(p+1,p+m+1,c[i].d)-p-1;
                int t2=upper_bound(p+1,p+m+1,td)-p-1;
                if(t1==t2) continue;
                ans1++;
                q[++tot].l=t1+1;
                q[tot].r=t2;
            }
        }
        // for(int i=1;i<=tot;i++){
        //     printf("%d %d\n",q[i].l,q[i].r);
        // }
        sort(q+1,q+tot+1,cmp);
        for(int i=1;i<=tot;i++){
            int lst=q[i].r;
            ans2++;
            i++;
            while(i<=tot&&q[i].l<=lst) i++;
            i--;
        }
        printf("%d %d\n",ans1,m-ans2);
    }
}
//hu ming hao AK IChO